import { ActionContext } from 'vuex'
import { IPermissionState } from './state'
import { IStore } from '@/store/types'
import { getMenu } from '@/api/base'

export const actions = {
  // 登录
  async getMenuPer({ commit }: ActionContext<IPermissionState, IStore>, params: any) {
    try {
      const res: any = await getMenu()
      commit('SET_MENUPERMISSION', res.data)
      commit('SET_BUTTONPERMISSION', Object.keys(res.data))
      return Promise.resolve(res)
    } catch (error) {
      return Promise.reject(error)
    }
  }
}
